@echo off
@REM  --------------------------------------------------------------------------------------
@REM  RunTests.bat file
@REM
@REM  This batch file tests the TestByWire by executing all unit tests.
@REM  By default, it tests a Debug build.
@REM  
@REM  Optional arguments for this batch file:
@REM    1 - Build type. Defaults to Debug
@REM  

echo.
echo =========================================================
echo   RunTests
echo      Tests TestByWire
echo =========================================================
echo.

set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319
set solutionDir="..\Source"
set buildType=Debug
set returnErrorCode=true
set pause=false

if not "%1"=="" set buildType=%1

@call MSTest /testcontainer:%solutionDir%\TestByWire.Test\bin\%buildType%\TestByWire.Test.dll /noresults
@if errorlevel 1 goto :error

@goto :exit

@REM  -------------------------------------------
@REM  Handle errors
@REM
@REM  Use the following after any call to exit
@REM  and return an error code when errors occur
@REM
@REM  if errorlevel 1 goto :error    
@REM  -------------------------------------------
:error
if %returnErrorCode%==false goto exit

@ECHO An error occured in RunTests.bat - %errorLevel%
if %pause%==true PAUSE
@exit errorLevel

@REM  ----------------------------------------
@REM  The exit label
@REM  ----------------------------------------
:exit
if %pause%==true PAUSE
